﻿using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2025-03-03
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 热处理记录
    /// </summary>
    [Verify]
    [Route("business/CksHeatTreatment")]
    [ApiExplorerSettings(GroupName = "business")]
    public class CksHeatTreatmentController : BaseController
    {
        /// <summary>
        /// 热处理记录接口
        /// </summary>
        private readonly ICksHeatTreatmentService _CksHeatTreatmentService;

        public CksHeatTreatmentController(ICksHeatTreatmentService CksHeatTreatmentService)
        {
            _CksHeatTreatmentService = CksHeatTreatmentService;
        }

        /// <summary>
        /// 查询热处理记录列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "cksheattreatment:list")]
        public IActionResult QueryCksHeatTreatment([FromQuery] CksHeatTreatmentQueryDto parm)
        {
            var response = _CksHeatTreatmentService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询热处理记录详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "cksheattreatment:query")]
        public IActionResult GetCksHeatTreatment(long Id)
        {
            var response = _CksHeatTreatmentService.GetInfo(Id);

            var info = response.Adapt<CksHeatTreatmentDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加热处理记录
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "cksheattreatment:add")]
        [Log(Title = "热处理记录", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCksHeatTreatment([FromBody] CksHeatTreatmentDto parm)
        {
            var modal = parm.Adapt<CksHeatTreatment>().ToCreate(HttpContext);

            var response = _CksHeatTreatmentService.AddCksHeatTreatment(modal);

            return SUCCESS(response);
        }

        [HttpPost("GetDegrees")]
        [ActionPermissionFilter(Permission = "cksheattreatment:list")]
        public IActionResult GetDegrees([FromBody] CksHeatTreatmentQueryDto parm)
        {
            var response = _CksHeatTreatmentService.GetDegrees(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 更新热处理记录
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "cksheattreatment:edit")]
        [Log(Title = "热处理记录", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCksHeatTreatment([FromBody] CksHeatTreatmentDto parm)
        {
            var modal = parm.Adapt<CksHeatTreatment>().ToUpdate(HttpContext);
            var response = _CksHeatTreatmentService.UpdateCksHeatTreatment(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除热处理记录
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "cksheattreatment:delete")]
        [Log(Title = "热处理记录", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCksHeatTreatment([FromRoute] string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_CksHeatTreatmentService.Delete(idArr));
        }

    }
}